import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/auth/Login',
    method: 'post',
    data
  })
}

export function fetchList(query) {
  return request({
    url: '/user',
    method: 'GET',
    params: query
  })
}

export function getInfo(token) {
  return request({
    url: '/auth/UserInfo',
    method: 'get',
    params: { token }
  })
}

export function getUser(id) {
  return request({
    url: `/user/${id}`,
    method: 'GET'
  })
}

export function saveUser(data) {
  return request({
    url: '/user',
    method: 'POST',
    data
  })
}

export function deleteUser(id) {
  return request({
    url: `/user/${id}`,
    method: 'DELETE'
  })
}

export function updateUser(data) {
  return request({
    url: `/user/${data.Id}`,
    method: 'PUT',
    data
  })
}

export function genpwd(id) {
  return request({
    url: `/user/genpwd/${id}`,
    method: 'GET'
  })
}

export function logout() {
  return request({
    url: '/vue-element-admin/user/logout',
    method: 'post'
  })
}
